<template>
  <div>
    <v-touch class="swiper-div" @swiperight="onSwiperRight" :swipe-options="{direction: 'horizontal'}">
      <head-top
        :title="headerTitle"
        :left-router="GLOBAL.pathSetting.product.main + '?tab=' + $route.params.type"
        :right-text="rightText"
        :right-router="rightRouter"
        :right-param="isAdmin ? { id: this.$route.params.id } : ''"
      ></head-top>
      <product-info></product-info>
    </v-touch>
  </div>
</template>

<script>
import ProductInfo from "@/components/product/info";
import HeadTop from "@/components/HeadTop";
export default {
  components: {
    ProductInfo,
    HeadTop,
  },
  name: 'ProductViewInfo',
  mounted() {
    const pathType = this.$route.params.type
    if (Number(pathType) === this.GLOBAL.listItemType.product.toStorage) {
      this.headerTitle = '拟入库商品详情'
    }
    if (Number(pathType) === this.GLOBAL.listItemType.product.storage) {
      this.headerTitle = '正式入库商品详情'
    }
    if (Number(pathType) === this.GLOBAL.listItemType.product.removed) {
      this.headerTitle = '已下架商品详情'
    }
    if (this.isAdmin) {
      if (Number(pathType) !== this.GLOBAL.listItemType.product.removed) {
        this.rightText = '编辑'
        this.rightRouter = '/product/' +pathType + '/edit/'
      }
    }
  },
  data() {
    return {
      headerTitle: '',
      rightText: '',
      rightRouter: '',
      isAdmin: this.$baseJS.getLoginUser().isAdmin
    };
  },
  methods: {
    onSwiperRight() {
      this.$router.go(-1)
    }
  },
};
</script>
<style scoped>
</style>
<style>
</style>